import 'package:flutter/material.dart';

/// UI辅助工具类，提供常用的UI相关功能
class UiHelper {
  /// 显示错误提示消息
  ///
  /// [context] - BuildContext对象
  /// [message] - 要显示的错误消息
  /// [duration] - SnackBar显示时长，默认为4秒
  static void showErrorMessage(
    BuildContext context,
    String message, {
    Duration duration = const Duration(seconds: 4),
  }) {
    if (context.mounted) {
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(
          content: Text(message),
          behavior: SnackBarBehavior.floating,
          shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
          backgroundColor: Colors.red.shade700,
          duration: duration,
        ),
      );
    }
  }

  /// 显示成功提示消息
  ///
  /// [context] - BuildContext对象
  /// [message] - 要显示的成功消息
  /// [duration] - SnackBar显示时长，默认为2秒
  static void showSuccessMessage(
    BuildContext context,
    String message, {
    Duration duration = const Duration(seconds: 2),
  }) {
    if (context.mounted) {
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(
          content: Text(message),
          behavior: SnackBarBehavior.floating,
          shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
          backgroundColor: Colors.green.shade700,
          duration: duration,
        ),
      );
    }
  }

  /// 显示信息提示消息
  ///
  /// [context] - BuildContext对象
  /// [message] - 要显示的信息
  /// [duration] - SnackBar显示时长，默认为2秒
  static void showInfoMessage(
    BuildContext context,
    String message, {
    Duration duration = const Duration(seconds: 2),
  }) {
    if (context.mounted) {
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(
          content: Text(message),
          behavior: SnackBarBehavior.floating,
          shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
          backgroundColor: Colors.blue.shade700,
          duration: duration,
        ),
      );
    }
  }
}